package data;

import java.util.ArrayList;
import java.util.List;

import data.room.Reservation;


/**
 * An implementation of Event to hold information about a meeting.
 * @author Erik
 *
 */
public class Meeting extends Appointment {

	private List<User> participants;
	
	public Meeting(String title, String description, 
			String location, User owner, Reservation reservation, List<User> participants) {
		super(title, description, location, 
				owner, reservation);
		
		if(participants == null) {
			this.participants = new ArrayList<User>();
		} else {
			this.participants = participants;
		}
	}

	/**
	 * Add a participant to this meeting.
	 * @param user The user to add
	 */
	public void addParticipant(User user) {
		if(user != getOwner()) {
			participants.add(user);
		}
		changeSupport.firePropertyChange("newParticipant", null, user);
	}
	
	/**
	 * Remove a participant from this meeting.
	 * @param user The user to remove
	 */
	public void removeParticipant(User user) {
		participants.remove(user);
		changeSupport.firePropertyChange("removeParticipant", null, user);
	}

	public List<User> getParticipants() {
		return participants;
	}

	public void setParticipants(List<User> participants) {
		if(participants.contains(getOwner())) {
			participants.remove(getOwner());
		}
		this.participants = participants;
		changeSupport.firePropertyChange("setParticipant", null, participants);
	}

}
